package com.hanthink.web.controller.manhour;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hanthink.common.annotation.Log;
import com.hanthink.common.core.controller.BaseController;
import com.hanthink.common.core.domain.AjaxResult;
import com.hanthink.common.enums.BusinessType;
import com.hanthink.system.domain.manhour.ManHourFactPlanData;
import com.hanthink.system.service.manhour.IManHourFactPlanDataService;
import com.hanthink.common.utils.poi.ExcelUtil;
import com.hanthink.common.core.page.TableDataInfo;

/**
 * 计划和实际用工分析Controller
 * 
 * @author hanthink
 * @date 2022-01-06
 */
@RestController
@RequestMapping("/manhour/ManHourFactPlanData")
public class ManHourFactPlanDataController extends BaseController
{
    @Autowired
    private IManHourFactPlanDataService manHourFactPlanDataService;

    /**
     * 查询计划和实际用工分析列表
     */
    @PreAuthorize("@ss.hasPermi('manhour:ManHourFactPlanData:list')")
    @GetMapping("/list")
    public TableDataInfo list(ManHourFactPlanData manHourFactPlanData)
    {
        startPage();
        List<ManHourFactPlanData> list = manHourFactPlanDataService.selectManHourFactPlanDataList(manHourFactPlanData);
        return getDataTable(list);
    }

    /**
     * 导出计划和实际用工分析列表
     */
    @PreAuthorize("@ss.hasPermi('manhour:ManHourFactPlanData:export')")
    @Log(title = "计划和实际用工分析", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ManHourFactPlanData manHourFactPlanData)
    {
        List<ManHourFactPlanData> list = manHourFactPlanDataService.selectManHourFactPlanDataList(manHourFactPlanData);
        ExcelUtil<ManHourFactPlanData> util = new ExcelUtil<ManHourFactPlanData>(ManHourFactPlanData.class);
        return util.exportExcel(list, "ManHourFactPlanData");
    }

    /**
     * 获取计划和实际用工分析详细信息
     */
    //@PreAuthorize("@ss.hasPermi('manhour:ManHourFactPlanData:query')")
    @GetMapping(value = "/{companyid}")
    public AjaxResult getInfo(@PathVariable("companyid") Long companyid)
    {
        return AjaxResult.success(manHourFactPlanDataService.selectManHourFactPlanDataById(companyid));
    }

    /**
     * 新增计划和实际用工分析
     */
    @PreAuthorize("@ss.hasPermi('manhour:ManHourFactPlanData:add')")
    @Log(title = "计划和实际用工分析", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ManHourFactPlanData manHourFactPlanData)
    {
        return toAjax(manHourFactPlanDataService.insertManHourFactPlanData(manHourFactPlanData));
    }

    /**
     * 修改计划和实际用工分析
     */
    @PreAuthorize("@ss.hasPermi('manhour:ManHourFactPlanData:edit')")
    @Log(title = "计划和实际用工分析", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ManHourFactPlanData manHourFactPlanData)
    {
        return toAjax(manHourFactPlanDataService.updateManHourFactPlanData(manHourFactPlanData));
    }

    /**
     * 删除计划和实际用工分析
     */
    @PreAuthorize("@ss.hasPermi('manhour:ManHourFactPlanData:remove')")
    @Log(title = "计划和实际用工分析", businessType = BusinessType.DELETE)
	@DeleteMapping("/{companyids}")
    public AjaxResult remove(@PathVariable Long[] companyids)
    {
        return toAjax(manHourFactPlanDataService.deleteManHourFactPlanDataByIds(companyids));
    }
}
